package com.edu.zut.security;

import com.edu.zut.mapper.RoleMapper;
import com.edu.zut.mapper.UserRoleMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.util.List;

/**
 * @Author 许文科
 * @Date 2023/1/13 13:31
 * @Description paperdetect-bcak
 */
@SpringBootTest
public class mysql {

    @Autowired
    private UserRoleMapper userRoleMapper;
    @Autowired
    private RoleMapper roleMapper;
    @Autowired
    private PasswordEncoder passwordEncoder;

    @Test
    public void show1() {
        List<Long> roleids = userRoleMapper.selectRoleIdsByUserId(1L);
        System.out.println(roleids);
    }

    @Test
    public void show2() {
        List<Long> roleids = userRoleMapper.selectRoleIdsByUserId(1L);
        List<String> roleKey = roleMapper.selectRoleNameByRoleIds(roleids);
        System.out.println(roleKey);
    }

//    @Test
//    public void show3() {
//        List<Long> roleids = userRoleMapper.selectRoleIdsByUserId(1L);
//        List<String> roleKey = roleMapper.selectRoleNameByRoleIds(roleids);
//
//        if (!passwordEncoder.matches(user.getPassword(), user1.getPassword())) {
//            throw new RuntimeException("密码错误，登录失败");
//        }
//        System.out.println(roleKey);
//    }
}
